<?

	if(isset($_GET['tid'])){

		$tid = intval($_GET['tid']);

	}else{

		header("Location: ".$_SESSION['url']."");

	}

	

	if(isset($_GET['cid'])){

		$cid = intval($_GET['cid']);

	}else{

		header("Location: ".$_SESSION['url']."");

	}

	

	if(isset($_GET['cm_id'])){

		$cm_id = intval($_GET['cm_id']);

	}

	

	if(isset($_GET['act'])){

		$act = $_GET['act'];

	}

	///////////////////SU LY COMMENT /////////////////////

	if(isset($_POST['submit'])){

		if($_SESSION['is_login'] == true){

			$txtComment = addslashes($_POST['txtComment']);

			$tid = $_POST['tid'];

			$uid = $_POST['uid'];

			$edit = $_POST['edit'];

			if($edit == '1'){

				$db->query("UPDATE ".$prefix."tintuc_comment SET cm_content = '".$txtComment."' WHERE cm_id = '".$cm_id."'");

				header("Location: ?mod=chitiettintuc&tid=".$tid."&cid=".$cid."");

			}else{

				$db->query("INSERT INTO ".$prefix."tintuc_comment(cm_nguoidung,cm_tintuc_id,cm_content,cm_date) VALUES('".$uid."','".$tid."','".$txtComment."',now())");

			}

		}

	}

	
$HomeLink = "<a href=\"".$root."/trang-chu/\">Trang chủ</a> ";
$HomeLink .= "&raquo; Tin tức";
?>

<? $_SESSION['url'] = getURL();?>

<div id="linkPath">

<div class="linkPath">

    <div class="corner-round-01-top-right">

        <div class="corner-round-01-top-left">

            <div class="corner-round-01-top-bg"></div>

        </div>



    </div>

    <div class="corner-round-01-body">    
       <span style="float: left;"><?=$HomeLink?></span>
        <?

			file_exist('includes/inc_thong_tin_rieng.php');

			include('includes/inc_thong_tin_rieng.php');	

		?>



        <div style="clear: both;"></div>

    </div>

    <div class="corner-round-01-bottom-right">

        <div class="corner-round-01-bottom-left">

            <div class="corner-round-01-bottom-bg"></div>

        </div>

    </div>   

</div>

    </div>

<?

	$rs = $db->query("SELECT * FROM ".$prefix."tintuc WHERE tt_id = '".$tid."' AND tt_hienthi = 1");

	if($db->num_rows($rs) == 0){

		header("Location: ".$_SESSION['url']."");

	}

	$row = $db->fetch_array($rs);

	$tt_tieude = $myString->unQuote(stripslashes($row[tt_tieude]));

	$tt_hinhanh = $PathFile . $row[tt_hinhanh];

	$tt_tomtat = $myString->unQuote(stripslashes($row[tt_tomtat]));

	$tt_noidung = $myString->unQuote(stripslashes($row[tt_noidung]));

	$tt_ngaythang = format_date($row[tt_ngaythang]);

	$tt_solanxem = $row[tt_solanxem];

	$tt_nguoidang = $myString->unQuote(stripslashes($row[tt_nguoidang]));

?>

    <!-- Main Page-Content { -->    

    <div id="page-content">    

        <div id="Div1" style="width:100%">             

            <div>

                <div style="width:733px;float:left;">

                    

<div id="news-list" style="padding-bottom:5px;">

    <div class="corner-round-02-top-right"><div class="corner-round-02-top-left"><div class="corner-round-02-top-bg"></div></div></div>

    <div class="corner-round-02-body">     

        <div style="padding:0 10px 10px 10px;">

            <div style="color:#FB6101;font-size:14px;margin-bottom:5px;"><strong><?=$tt_tieude?></strong></div>



            <p style="border-bottom:dashed 1px #CCCCCC;line-height:1px;"></p>

        </div>             

        <div style="padding: 0px 10px 0px 10px;">

           	<p style="font-weight:bold; color:#373737;"><?=$tt_tomtat?></p>

			<br />

			<p align="center">

				<?

					list($width, $height) = getimagesize($tt_hinhanh);

					if($width <= 300){

						echo "<img src=\"".$root."/".$tt_hinhanh."\" border=\"0\" onerror=\"this.src='".$root."/themes/images/noimg.jpg';\">";

					}else{

						echo "<img src=\"".$root."/".$tt_hinhanh."\" border=\"0\" width=\"300\" onerror=\"this.src='".$root."/themes/images/noimg.jpg';\">";

					}

				?>

			</p>

			<br />

			<?=$tt_noidung?>

        </div>

        <br/><br/>

        <div style="color:#666666;font-size:8pt;text-align:right;padding-right:10px;">

			<i>Người đăng: <?=$tt_nguoidang?></i>

			<br />

            <i>Thời gian: <?=$tt_ngaythang?></i>

        </div>

        

    </div>

    <div class="corner-round-02-bottom-right">

        <div class="corner-round-02-bottom-left">

            <div class="corner-round-02-bottom-bg"></div>

        </div>

    </div>   

</div>               

                    



<!-- COMMENT NEWS -->



<a name="comment" id="comment"></a>



<div id="product-comments">    

    <div class="product-detail-inner">

        <div class="corner-round-02-top-right"><div class="corner-round-02-top-left"><div class="corner-round-02-top-bg"></div></div></div>

        <div class="corner-round-02-body" style="height:auto;overflow:hidden;">



        <table width="100%" cellpadding="0" cellspacing="0">

            <tr>

                <td>                               

                   

                    <div id="product-comment">

                              

	<?

		$sql = "SELECT * FROM ".$prefix."tintuc_comment WHERE cm_tintuc_id = '".$tid."' ORDER BY cm_id DESC";

		$pp=10; 

		$parr=array();

		$parr=paging($sql,$pp);

		$page=$parr[0];

		$limitvalue=$parr[1];

		$numofpages=$parr[2];

		$sql.=" LIMIT $limitvalue, $pp";

		$rs3 = $db->query($sql);

	if($db->num_rows($rs3) != 0){

		$st = 0;

		while($row3 = $db->fetch_array($rs3)){

		$st++;

		$cm_id = $row3[cm_id];

		$cm_date = format_date_time($row3[cm_date]);

		$cm_content = $myString->unQuote(stripslashes($row3[cm_content]));

		$cm_nguoidung = $row3[cm_nguoidung];

		$cm_ten_nguoidung = tenNguoiDung($cm_nguoidung);

		$cm_avatar_nguoidung = $PathThumbFile . loadAvatar($cm_nguoidung);

		$cm_chuky_nguoidung = loadChuKy($cm_nguoidung);

	?>

							  

						<!-- LIST Comment { -->	                                                  

                            <div class="product-comment-item" style="height:auto;overflow:hidden;">

                                

                                <div style="height:14px;background-color:#FFFFFF;font-size:8pt;line-height:14px;margin-bottom:5px;color:#666666;">

                                    <div style="float:left">

                                        <?=$cm_date?>                                       

                                    </div>



                                    <div style="float:right; padding-right:20px;">

                                        #<?=$st?>                                       

                                    </div>   

                                </div>  

                                <div class="clearBoth" /></div>

                                

								<div class="panel-left">

                              <table cellpadding="0" cellspacing="0" border="0">

							  <tr>

							  <td>      

                                     <div class="picture-profile1" style="margin-bottom:5px;">

                                        <p>                                                

                                            <a extag="own" title="<?=$cm_ten_nguoidung?>" href="<?=$root?>/shop-<?=$cm_nguoidung?>/<?=tenNguoiDung2($cm_nguoidung)?>">

                                                <img width="60px" alt="<?=$cm_ten_nguoidung?>" src="<?=$root?>/<?=$cm_avatar_nguoidung?>" onerror="this.src='<?=$root?>/themes/images/noavatar.jpg';"/>

                                            </a>



                                        </p>

                                        <p style="text-align:left">

                                            <a extag="own" class="seller" href="<?=$root?>/shop-<?=$cm_nguoidung?>/<?=tenNguoiDung2($cm_nguoidung)?>" title="<?=$cm_ten_nguoidung?>">

                                            <span class="sellername"><?=$myString->cutString2($cm_ten_nguoidung,6)?></span>

                                            </a>

                                        </p>

                                     </div>    

                                 </td><td valign="top">

								 

								  <div class="message" style="padding-left:5px;">



									<!-- CONTENT -->  

                                    <?=$cm_content?>

									    

                                    </div> 

								 

								 </td></tr></table>                        

                                </div>   

                                

								<div class="panel-right">

                                     

                                    <div class="signature">   

										<?=$cm_chuky_nguoidung?>

									</div>

                                    <div class="date1" style="margin-top:5px;font-style:normal;font-size:8pt;margin-right:20px; text-align:right;">

									<?

										if($_SESSION['is_login'] == true && $_SESSION['uid'] == $cm_nguoidung){

									?>

									<a extag="own" class="link-edit" href="<?=$root?>/?mod=chitiettintuc&tid=<?=$tid?>&act=edit_comment&cid=<?=$cid?>&cm_id=<?=$cm_id?>" style="font-style: normal; font-size: 8pt;">Cập nhật</a> | 

									

									<? } ?>

									

                                    <? 

									 if($_SESSION['is_login'] == true && ($_SESSION['uid'] == $t_nguoidang || $_SESSION['uid'] == $cm_nguoidung) ){

									?>

									

									<a class="link-delete" extag="own" href="javascript:;" onclick="javascript: confirmDelete('<?=$root?>/action.php?act=del_news_comment&id=<?=$cm_id?>&u_id=<?=$_SESSION['uid']?>');">Xóa</a> | 

									<? } ?>

                                        <a extag="own" title="Trích dẫn nội dung bài viết" href="<?=$root?>/?mod=chitiettintuc&tid=<?=$tid?>&act=quote_comment&cid=<?=$cid?>&cm_id=<?=$cm_id?>"  style="font-style:normal;font-size:8pt;" class="quote">Trích dẫn</a> | 

                                        

                                        <a extag="own" class="link-alert" title="Báo cho quản trị về nội dung thông tin." href="<?=$root?>/gop-y/">

                                            Báo quản trị

                                        </a>                    

                                    

                                    </div>                                     

                                </div>  

								                                    

                            </div> 

							    

                            <div class="bar" style="padding-top:5px;"></div> 

                          <!--  } LIST Comment -->                                                    

       <? } ?>   

	   		<br />

			 <p align="left" class="font" style="padding-left:320px;">

				 <?php echo page_div( "".$root."/?mod=chitiettintuc&tid=".$pid."&cid=".$cid."&p=%d_pg", "10", ceil ( $numofpages ), $page ); ?>

			 </p> 

			 <br />                

<? }else{ ?>



	<div class="product-comment-item" style="height:auto;overflow:hidden;">

		<p align="center"><b>Chưa có comment nào !</b></p>

	</div>

<? } 

	

	if($_SESSION['is_login'] == true){

?>

                    

                    <p class="message-bar" style="margin-top:10px;"></p>

					

<form action="" name="frmComment" id="frmComment" method="post">                    

                   

				   <div style="padding-left:40px; margin-top:10px;">

                    <?

						

				if($act == "quote_comment"){						

						$rs4 = $db->query("SELECT * FROM ".$prefix."sanpham_comment WHERE cm_id = '".$cm_id."'");

						if($db->num_rows($rs4) != 0){	

							$row4 =$db->fetch_array($rs4);

							$txtContent = $myString->unQuote(stripslashes($row4[cm_content]));

							$cm_ten_nguoidung = tenNguoiDung($row4[cm_nguoidung]);

						}else{

							reHome($urlHome);

						}

					?>		

							<textarea id="elm1" name="txtComment" style="width:560px;height:300px;font-family:Verdana;font-size:10pt;border:solid 1px #CCCCCC">

							Nguyên văn bởi : <b><?=$cm_ten_nguoidung?></b>

							<br /><br />

							<div style="padding-left: 10px;">

							<i><?=$txtContent?></i>

							</div>

							<br />

							-----------------------------------------

							<br /><br />

							</textarea>

                 <? }else if($act == "edit_comment"){ 

				 		$rs4 = $db->query("SELECT * FROM ".$prefix."sanpham_comment WHERE cm_id = '".$cm_id."'");

						if($db->num_rows($rs4) != 0){	

							$row4 =$db->fetch_array($rs4);

							$txtContent = $myString->unQuote(stripslashes($row4[cm_content]));

						}else{

							reHome($urlHome);

						}

				 ?>

				 	<textarea id="elm1" name="txtComment" style="width:560px;height:300px;font-family:Verdana;font-size:10pt;border:solid 1px #CCCCCC"><?=$txtContent?></textarea>

					<input type="hidden" name="edit" id="edit" value="1" />

					<input type="hidden" name="cm_id" id="cm_id" value="<?=$cm_id?>" />

				 

				 <? }else{ ?>

				 		<textarea id="elm1" name="txtComment" style="width:560px;height:300px;font-family:Verdana;font-size:10pt;border:solid 1px #CCCCCC"></textarea>

				 <? } ?>      

                   

					

                    <div style="margin-top:10px; margin-right:75px;" align="right">

                        <p style="line-height:20px;">

						

                        <span id="Error Save" style="color:Red;font-weight:bold;"></span>

                        	<input type="hidden" name="submit" id="submit" value="submit" />

							<input type="hidden" name="tid" id="tid" value="<?=$tid?>" />

							<?

								$uid = $_SESSION['uid'];

							?>

							<input type="hidden" name="uid" id="uid" value="<?=$uid?>"/>

                            <input id="txtSave" name="txtSave" type="image" src="<?=$root?>/themes/images/home/btncomment.jpg" />&nbsp;



                       

                        </p>

                    </div>

					

					</div>

</form>

<? } ?>

                </td>

            </tr>

        </table>   

        </div>   

        <div class="corner-round-02-bottom-right">

		<div class="corner-round-02-bottom-left"><div class="corner-round-02-bottom-bg"></div></div></div>

    </div>    

</div>



<!-- COMMENT NEWS --> 

                      

                </div>

                <div style="float:left;width:240px;margin-left:5px;">

                    

<!-- Menu Left { -->

<?

	file_exist('includes/inc_menu_left_tintuc.php');

	include('includes/inc_menu_left_tintuc.php');

?>

<!-- } Menu Left -->   

                    

<div style="padding:5px;padding-top:10px;">

    <div style="padding:0 0px 0px 0px;">

        <div style="font-size:12px;margin-bottom:3px;padding-left:0px;color:#447788">Tin mới đăng</div>

        <p style="border-bottom:dashed 1px #DDDDDD;line-height:1px;"></p>

    </div>        

    <div id="news-items-list">

  

 <?	

 	if($cid != 0){

 		$sql = "SELECT * FROM ".$prefix."tintuc WHERE tt_loaitintuc = '".$cid."' AND tt_hienthi = 1 ORDER BY tt_id DESC LIMIT 10";

	}else{

		$sql = "SELECT * FROM ".$prefix."tintuc WHERE tt_hienthi = 1 ORDER BY tt_id DESC LIMIT 10";

	}

 	$rs = $db->query($sql);

	

	while($row = $db->fetch_array($rs)){

	$tt_id = $row[tt_id];

	$cid = $row[tt_loaitintuc];

	$tt_tieude = $myString->unQuote(stripslashes($row[tt_tieude]));

	$tt_hinhanh = $PathThumbFile . $row[tt_hinhanh];

 ?>  

        

		<!-- TIN MOI DANG -->

		

                <div style="padding:5px 0px 3px 0px;text-align:left;border-bottom:dashed 1px #CCCCCC;">



                    <p>

                        <a style="font-size:9pt;" title="<?=$tt_tieude?>" href="<?=$root?>/chi-tiet-tin-tuc/<?=$tt_id?>/<?=$cid?>/<?=$myString->vietdecode($tt_tieude)?>">

                            <img align="left" style="margin-right:4px;border:solid 1px #F1F1F1;" src="<?=$root?>/<?=$tt_hinhanh?>" alt="<?=$tt_tieude?>" width="50" height="50" border="0" onerror="this.src='<?=$root?>/themes/images/noimg.jpg';"> 

                        </a>

                        <a style="font-size:9pt;" href="<?=$root?>/chi-tiet-tin-tuc/<?=$tt_id?>/<?=$cid?>/<?=$myString->vietdecode($tt_tieude)?>">

                           <?=$tt_tieude?>

                        </a>     

                    </p>        

                    <div style="clear:both;"></div>        

                </div>   

				              

          <!-- TIN MOI DANG -->  



  <? } ?>             

     </div>

    <div style="height:10px"></div>       

</div>

 

                </div>

            </div>

            <div style="clear:both;"></div>



        </div>             

    </div>

    <div style="clear:both;"></div>   

    <br />   

    <!-- } Main Page-Content -->  



              

            </div>

